********Table F.1 - Mexico********

*Load data
cd "$reploc/data/created_data"
use mex_full, clear

*Do these results for primary sample
sort pid_link mxfls
foreach var of varlist rbuc_nga grbrprovAvg_lam0co3 grbrprovSD_lam0co3 inflation{
gen `var'dif=`var'-`var'[_n-1] if mxfls==3 & pid_link==pid_link[_n-1]
}

gen coh_prov_clust=yearprov

gen primarysample1=0
replace primarysample1=1 if rbuc_ngadif!=. & grbrprovAvg_lam0co3dif!=. & grbrprovSD_lam0co3dif!=. & inflationdif!=. &  birthyr>=1925 & coh_prov_clust!=.

egen primarysample=total(primarysample1), by(pid_link)

keep if primarysample==1

quietly tab mxfls, gen(Idum)

*Regression

local regvars entrep evermig income_ia assets_ia savingtotal_ia borrowingtotal_ia aggexpcons_ia smoke smoketot woman imp_age imp_age_sq 
local controls  Idum2 married Eddum* i.ent hhsize

local x rbuc 

reg `x' `regvars' `controls', robust cluster(coh_prov_clust)

cd "$reploc/results"
outreg2 using TableF1_Mexico.tex, replace label keep(`regvars') dec(2) sdec(2)
